﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace DomainInfoLib
{
    public delegate void GottenRegisteInfoHandle(QueryItem item);

    /// <summary>
    /// 查询项
    /// </summary>
    public class QueryItem
    {
        public string Domain { get; set; }

        public string KeyWord { get; set; }

        public string PreFix { get; set; }

        public string SurFix { get; set; }

        public string DomainName
        {
            get 
            {
                return PreFix + KeyWord + SurFix;
            }
        }

        public string DomainFullName 
        {
            get
            {
                return DomainName + Domain;
            }
        }

        public RegisterInfo RegisteInfo { get;  set; }

        public event GottenRegisteInfoHandle Done;

        public bool? Avaliable()
        {
            if (RegisteInfo==null)
            {
                return null;
            }
            return RegisteInfo.Avaliable;
        }

        internal void GetRegisteInfo()
        {

            RegisteInfo = DiggerServer.GetResponse(DomainFullName);

            Done(this);
        }



        public string GetResponseStr()
        {
            if (RegisteInfo==null)
	        {
		        return "无返回值";
	        }

            return RegisteInfo.Response;
        }

        public string GetAPIName()
        {
            if (RegisteInfo == null)
            {
                return "无返回值";
            }

            return RegisteInfo.APIName;
        }
    }
}
